package com.fingard.dsp.bank.reqrespobj.qryrefund;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RequestBase;
import com.fingard.text.StringHelper;
import com.fingard.util.DateHelper;
import com.fingard.xml.XmlTextReader;

import java.text.ParseException;
import java.util.Date;

public class ReqQryRefund extends RequestBase {
    public String payBank = "";
    public String payAct = "";
    public String payCur = "";
    public String payActName = "";
    public String payBankLocationsName = "";
    public String qryStartDate = "";
    public String qryEndDate = "";
    public String areaCode = "";
    //是否虚拟户
    public boolean isVirtual;
    //虚拟户编号
    public String virtualNo;

    public ReqQryRefund(XmlTextReader p_xmlReader, ReqRespHeader p_header) throws Exception {
        reqHeader = p_header;
        payBank = p_xmlReader.getSimpleTextNotNull("PayBank");
        payAct = p_xmlReader.getSimpleTextNotNull("PayAct");
        payCur = p_xmlReader.getSimpleTextNotNull("PayCur");
        payActName = p_xmlReader.getSimpleTextNotNull("PayActName");
        payBankLocationsName = p_xmlReader.getSimpleTextNotNull("PayBankLocationsName");
        qryStartDate = p_xmlReader.getSimpleTextNotNull("QueeStartDate");
        qryEndDate = p_xmlReader.getSimpleTextNotNull("QueeEndDate");
        areaCode = p_xmlReader.getSimpleTextNotNull("AreaCode");
        if ("1".equals(p_xmlReader.getSimpleTextNotNull("IsVirtual"))) {
            isVirtual = true;
        } else {
            isVirtual = false;
        }
        virtualNo = p_xmlReader.getSimpleTextNotNull("VirtualNo");
    }

    public Date getQryStartDate() throws ParseException {
        if (StringHelper.isNullOrEmpty(qryStartDate)) {
            return new Date();
        }
        return DateHelper.convertToDateExtra(qryStartDate);
    }

    public Date getQryEndDate() throws ParseException {
        if (StringHelper.isNullOrEmpty(qryEndDate)) {
            return new Date();
        }
        Date endDate = DateHelper.convertToDateExtra(qryEndDate);
        if (endDate == null) {
            return getQryStartDate();
        } else {
            return endDate;
        }
    }

}
